package com.ymatou.iapi.trading.sellerquery2.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.query.seller.trading.api.parameter.ExportSellerOrderInfosResponse;
import com.ymatou.query.seller.trading.api.parameter.GetExportOrderInfoResult;
import com.ymatou.query.seller.trading.api.parameter.SellerExportedOrderInfo;
import com.ymatou.query.seller.trading.api.parameter.Ymt_O_OrderNote;
import com.ymatou.query.seller.trading.api.parameter.Ymt_Order;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderInfo;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderState;
import com.ymatou.query.seller.trading.api.parameter.Ymt_OrderSummary;
import com.ymatou.query.seller.trading.api.service.OrderCreate;
import com.ymatou.query.trading.api.parameter.GetExportOrderInfo;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.common.order.sellerquery2.Convertor;
import com.ymttest.common.order.sellerquery2.ExportOrderInfo;
import com.ymttest.common.order.sellerquery2.TimeRange;
import com.ymttest.common.order.sellerquery2.bean.ExportSellerOrderInfosBean;
import com.ymttest.common.order.sellerquery2.model.SellerExportOrderQueryModel;
import com.ymttest.common.order.sellerquery2.sp.Sp_GetExportOrderInfoByOrderIds_v1;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;

/**
 * @date 2016-06-28
 * @author songyefeng
 * @desc 分批导出卖家订单信息
 */
@TestSuite
public class Ts_ExportSellerOrderInfos {

	private static ExportSellerOrderInfosBean request;
	// private static
	// com.ymatou.query.seller.trading.api.service.ExportSellerOrderInfosCall
	// call;
	private static com.ymatou.iapi.trading.sellerquery2.service.ExportSellerOrderInfosCall call;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分批导出卖家订单信息");
	}

	@Before
	public void caseUp() {
		request = new ExportSellerOrderInfosBean();
		// call = new
		// com.ymatou.query.seller.trading.api.service.ExportSellerOrderInfosCall();
		call = new com.ymatou.iapi.trading.sellerquery2.service.ExportSellerOrderInfosCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verify() {
		ExportSellerOrderInfosResponse expectedResponse = new ExportSellerOrderInfosResponse();
		ConstructExpectedResponse(expectedResponse);
		ExportSellerOrderInfosResponse actualResponse = call
				.getExportSellerOrderInfosResponse();
		DataUtil.verify(expectedResponse.getSellerExportedPartialOrderInfos()
				.size(), actualResponse.getSellerExportedPartialOrderInfos()
				.size(), "验证SellerExportedPartialOrderInfos的订单数量");
		if (DataUtil.isNullOrEmpty(expectedResponse
				.getSellerExportedPartialOrderInfos()) == false) {
			List<SellerExportedOrderInfo> actuals = actualResponse
					.getSellerExportedPartialOrderInfos();
			for (SellerExportedOrderInfo expect : expectedResponse
					.getSellerExportedPartialOrderInfos()) {
				boolean exists = actuals.stream().anyMatch(
						x -> x.getOrderNo() == expect.getOrderNo());
				DataUtil.verify(true, exists,
						"验证orderno:" + expect.getOrderNo() + "是否存在");
				if (exists) {
					SellerExportedOrderInfo actual = actuals.stream()
							.filter(x -> x.getOrderNo() == expect.getOrderNo())
							.collect(Collectors.toList()).get(0);
					DataUtil.verify(expect.getAddress(), actual.getAddress(),
							"验证orderno:" + actual.getOrderNo() + "的Address");
					DataUtil.verifyDateEquals(expect.getAddTime(),
							actual.getAddTime(),
							"验证orderno:" + actual.getOrderNo() + "的AddTime");
					DataUtil.verifyDateEquals(expect.getApplyPostPayTime(),
							actual.getApplyPostPayTime(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ApplyPostPayTime");
					DataUtil.verify(expect.getBondedArea(),
							actual.getBondedArea(),
							"验证orderno:" + actual.getOrderNo() + "的BondedArea");
					DataUtil.verify(expect.getBuyerLoginId(),
							actual.getBuyerLoginId(),
							"验证orderno:" + actual.getOrderNo()
									+ "的BuyerLoginId");
					DataUtil.verifyDecimalEquals(expect.getCashAmount(),
							actual.getCashAmount(),
							"验证orderno:" + actual.getOrderNo() + "的CashAmount");
					// DataUtil.verify(expect.getCatalogInfos(),
					// actual.getCatalogInfos(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的CatalogInfos");
					// DataUtil.verify(expect.getCatalogStatus(),
					// actual.getCatalogStatus(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的CatalogStatus");
					DataUtil.verify(expect.getCatalogType(),
							actual.getCatalogType(),
							"验证orderno:" + actual.getOrderNo() + "的CatalogType");
					// DataUtil.verify(expect.getDeliveryType(),
					// actual.getDeliveryType(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的DeliveryType");
					DataUtil.verifyDecimalEquals(expect.getDepositAmount(),
							actual.getDepositAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的DepositAmount");
					DataUtil.verifyDateEquals(expect.getDispathTime(),
							actual.getDispathTime(),
							"验证orderno:" + actual.getOrderNo() + "的DispathTime");
					DataUtil.verifyDecimalEquals(expect.getFreight(),
							actual.getFreight(),
							"验证orderno:" + actual.getOrderNo() + "的Freight");
					// DataUtil.verify(expect.getIsPaidInFull(),
					// actual.getIsPaidInFull(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的IsPaidInFull");
					// DataUtil.verify(true, actual.getIsPaidInFull(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的IsPaidInFull");
					DataUtil.verify(expect.getLeaveWord(),
							actual.getLeaveWord(),
							"验证orderno:" + actual.getOrderNo() + "的LeaveWord");
					// DataUtil.verify(expect.getLogisticsCode(),
					// actual.getLogisticsCode(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的LogisticsCode");
					DataUtil.verify(true, actual.getLogisticsCode() != null,
							"验证orderno:" + actual.getOrderNo()
									+ "的LogisticsCode");
					// DataUtil.verify(expect.getLogisticsCompany(),
					// actual.getLogisticsCompany(),
					// "验证orderno:" + actual.getOrderNo()
					// + "的LogisticsCompany");
					DataUtil.verify(true, actual.getLogisticsCompany() != null,
							"验证orderno:" + actual.getOrderNo()
									+ "的LogisticsCompany");
					DataUtil.verify(DataUtil.Stringg.getValueOrDefault(expect
							.getOrderNote()), DataUtil.Stringg
							.getValueOrDefault(actual.getOrderNote()),
							"验证orderno:" + actual.getOrderNo() + "的OrderNote");
					DataUtil.verify(expect.getOrderState(),
							actual.getOrderState(),
							"验证orderno:" + actual.getOrderNo() + "的OrderState");
					// DataUtil.verify(expect.getOrderType(),
					// actual.getOrderType(),
					// "验证orderno:" + actual.getOrderNo() + "的OrderType");
					DataUtil.verify(DataUtil.Booleann.GetValueOrDefault(expect
							.getPackageDelivery_DomesticDelivered()),
							DataUtil.Booleann.GetValueOrDefault(actual
									.getPackageDelivery_DomesticDelivered()),
							"验证orderno:" + actual.getOrderNo()
									+ "的PackageDelivery_DomesticDelivered");
					DataUtil.verifyDateEquals(expect.getPayTime(),
							actual.getPayTime(),
							"验证orderno:" + actual.getOrderNo() + "的PayTime");
					DataUtil.verify(expect.getPhone(), actual.getPhone(),
							"验证orderno:" + actual.getOrderNo() + "的Phone");
					DataUtil.verify(expect.getPostCode(), actual.getPostCode(),
							"验证orderno:" + actual.getOrderNo() + "的PostCode");
					DataUtil.verifyDecimalEquals(expect.getPostPayAmount(),
							actual.getPostPayAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的PostPayAmount");
					DataUtil.verifyDateEquals(expect.getPostPayTime(),
							actual.getPostPayTime(),
							"验证orderno:" + actual.getOrderNo() + "的PostPayTime");
					DataUtil.verify(expect.getProductNames(),
							actual.getProductNames(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ProductNames");
					DataUtil.verify(DataUtil.Stringg.getValueOrDefault(expect
							.getProductNos()), DataUtil.Stringg
							.getValueOrDefault(actual.getProductNos()),
							"验证orderno:" + actual.getOrderNo() + "的ProductNos");
					DataUtil.verify(expect.getProductNum(),
							actual.getProductNum(),
							"验证orderno:" + actual.getOrderNo() + "的ProductNum");
					DataUtil.verify(expect.getProductPrice(),
							actual.getProductPrice(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ProductPrice");
					DataUtil.verify(expect.getReceivePerson(),
							actual.getReceivePerson(),
							"验证orderno:" + actual.getOrderNo()
									+ "的ReceivePerson");
					DataUtil.verifyDecimalEquals(expect.getRefundAmount(),
							actual.getRefundAmount(),
							"验证orderno:" + actual.getOrderNo()
									+ "的RefundAmount");
					DataUtil.verify(expect.getRemarkLevel(),
							actual.getRemarkLevel(),
							"验证orderno:" + actual.getOrderNo() + "的RemarkLevel");
					DataUtil.verify(expect.getRiskVerifiedStatus(),
							actual.getRiskVerifiedStatus(), "验证orderno:"
									+ actual.getOrderNo()
									+ "的RiskVerifiedStatus");
					DataUtil.verifyDecimalEquals(DataUtil.BigDecimall
							.GetValueOrDefault(expect.getSellerCouponAmount()),
							actual.getSellerCouponAmount(), "验证orderno:"
									+ actual.getOrderNo()
									+ "的SellerCouponAmount");
					DataUtil.verify(expect.getTelephone(),
							actual.getTelephone(),
							"验证orderno:" + actual.getOrderNo() + "的Telephone");
					DataUtil.verifyDecimalEquals(expect.getTotalAmount(),
							actual.getTotalAmount(),
							"验证orderno:" + actual.getOrderNo() + "的TotalAmount");
				}
			}
		}
	}

	private void ConstructExpectedResponse(
			ExportSellerOrderInfosResponse response) {
		Process(response);
	}

	private void Process(ExportSellerOrderInfosResponse response) {
		SellerExportOrderQueryModel model = Convertor
				.SellerExportOrderRequestArguments(request);
		ExportSellerOrderInfosResponseProcessor(model, response);
	}

	@SuppressWarnings("rawtypes")
	private void ExportSellerOrderInfosResponseProcessor(
			SellerExportOrderQueryModel model,
			ExportSellerOrderInfosResponse response) {
		Sp_GetExportOrderInfoByOrderIds_v1 sp = ExportOrderInfo
				.GetExportSellerOrderInfoListSqlCommand(model);
		List<Map> orders = sp.getOrders();
		List<Map> orderInfos = sp.getOrderInfos();
		List<Map> orderNotes = sp.getOrderNotes();
		List<Map> orderStates = sp.getOrderStates();
		List<Map> orderSummaries = sp.getOrderSummarys();
		GetExportOrderInfoResult result = ConvertResult(orders, orderInfos,
				orderNotes, orderStates, orderSummaries);
		if (DataUtil.isNullOrEmpty(result.getOrders())) {
			response.setSellerExportedPartialOrderInfos(new ArrayList<SellerExportedOrderInfo>());
			response.setNextPartitionKey(null);
			return;
		}
		String nextPartitionKey = result.getOrders().size() < ExportOrderInfo.MAX_PER_QUERY_COUNT
				? null
				: String.valueOf(result.getOrders().stream()
						.min((a, b) -> a.getiOrderId() - b.getiOrderId()).get()
						.getiOrderId());
		response.setNextPartitionKey(nextPartitionKey);
		response.setSellerExportedPartialOrderInfos(GetExportOrderInfo
				.GetExportOrderInfos(result));
	}

	@SuppressWarnings("rawtypes")
	private GetExportOrderInfoResult ConvertResult(List<Map> orders,
			List<Map> orderInfos, List<Map> orderNotes, List<Map> orderStates,
			List<Map> orderSummaries) {
		GetExportOrderInfoResult result = new GetExportOrderInfoResult();
		List<Ymt_Order> Orders = new ArrayList<Ymt_Order>();
		List<Ymt_OrderInfo> OrderInfos = new ArrayList<Ymt_OrderInfo>();
		List<Ymt_O_OrderNote> OrderNotes = new ArrayList<Ymt_O_OrderNote>();
		List<Ymt_OrderState> OrderStates = new ArrayList<Ymt_OrderState>();
		List<Ymt_OrderSummary> OrderSummaries = new ArrayList<Ymt_OrderSummary>();
		if (false == DataUtil.isNullOrEmpty(orders)) {
			for (Map m : orders) {
				Ymt_Order order = new Ymt_Order();
				DataUtil.mapToBean(order, m);
				Orders.add(order);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderInfos)) {
			for (Map map : orderInfos) {
				Ymt_OrderInfo oi = new Ymt_OrderInfo();
				DataUtil.mapToBean(oi, map);
				OrderInfos.add(oi);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderNotes)) {
			for (Map map : orderNotes) {
				Ymt_O_OrderNote note = new Ymt_O_OrderNote();
				DataUtil.mapToBean(note, map);
				OrderNotes.add(note);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderStates)) {
			for (Map map : orderStates) {
				Ymt_OrderState state = new Ymt_OrderState();
				DataUtil.mapToBean(state, map);
				OrderStates.add(state);
			}
		}
		if (false == DataUtil.isNullOrEmpty(orderSummaries)) {
			for (Map map : orderSummaries) {
				Ymt_OrderSummary summary = new Ymt_OrderSummary();
				DataUtil.mapToBean(summary, map);
				OrderSummaries.add(summary);
			}
		}
		result.setOrders(Orders);
		result.setOrderInfos(OrderInfos);
		result.setOrderNotes(OrderNotes);
		result.setOrderStates(OrderStates);
		result.setOrderSummaries(OrderSummaries);
		return result;
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_001() {
		Logger.start(true, "分批导出卖家订单信息");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-8,
					YMTDateUtil.YMDTHMS_STRING));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-7,
					YMTDateUtil.YMDTHMS_STRING));
			request.setPaidTime(paidTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_002() {
		Logger.start(true, "分批导出卖家订单信息, 测试paidTime筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-9,
					YMTDateUtil.YMDTHMS_STRING));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-5,
					YMTDateUtil.YMDTHMS_STRING));
			request.setPaidTime(paidTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_003() {
		Logger.start(true, "分批导出卖家订单信息, 测试订单状态为17的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.SellerAccept.getValue());
			request.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-9,
					YMTDateUtil.YMDTHMS_STRING));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-5,
					YMTDateUtil.YMDTHMS_STRING));
			request.setPaidTime(paidTime);
			call.setData(request);
			call.callService();
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_004() {
		Logger.start(true, "分批导出卖家订单信息, paidTime的end为空");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.Received.getValue());
			request.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-10,
					YMTDateUtil.YMDTHMS_STRING));
			request.setPaidTime(paidTime);
			call.setData(request);
			call.callService();
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_005() {
		Logger.start(true, "分批导出卖家订单信息, paidTime的start为空");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.Received.getValue());
			request.setOrderStatus(orderStatus);
			TimeRange paidTime = new TimeRange();
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-9,
					YMTDateUtil.YMDTHMS_STRING));
			request.setPaidTime(paidTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_008() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-6,
					YMTDateUtil.YMDTHMS_STRING));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-5,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	public void Tc_ExportSellerOrderInfos_009() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-9,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	public void Tc_ExportSellerOrderInfos_010() {
		Logger.start(true, "分批导出卖家订单信息, 测试CreatedTime的筛选,只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_011() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,begin+end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-9,
					YMTDateUtil.YMDTHMS_STRING));
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-5,
					YMTDateUtil.YMDTHMS_STRING));
			request.setDeliveredTime(deliveredTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	public void Tc_ExportSellerOrderInfos_012() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,只有begin");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-9,
					YMTDateUtil.YMDTHMS_STRING));
			request.setDeliveredTime(deliveredTime);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	@Ignore
	public void Tc_ExportSellerOrderInfos_013() {
		Logger.start(true, "分批导出卖家订单信息, 测试DeliveredTime的筛选,只有end");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0,
					YMTDateUtil.YMDTHMS_STRING));
			request.setDeliveredTime(deliveredTime);
			request.setOrderId(112501755);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_014() {
		Logger.start(true, "分批导出卖家订单信息, 测试LogisticsTypes的筛选");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3,
					YMTDateUtil.YMDTHMS_STRING));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);
			List<Integer> logisticsTypes = new ArrayList<Integer>();
			logisticsTypes.add(LogisticsTypeEnum.SailProtect.getValue());

			request.setLogisticsTypes(logisticsTypes);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_015() {
		Logger.start(true, "分批导出卖家订单信息, 测试OrderId的筛选");
		try {
			Logger.comment("准备订单数据");
			OrderCreate o = new OrderCreate();
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int orderId = o.create1_M2cOrder(userId, sellerId).getiOrderId();
			Thread.sleep(2000l);
			Logger.comment("完成准备订单数据");
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			request.setOrderId(orderId);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_016() {
		Logger.start(true, "分批导出卖家订单信息, 测试OrderId的筛选(订单不存在)");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.AccountPaid.getValue());
			orderStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			request.setOrderId(404);
			request.setOrderStatus(orderStatus);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_023() {
		Logger.start(true, "分批导出卖家订单信息失败, SellerId为null");
		try {
			request.setSellerId(null);
			request.setProductName("接口自动化测试Test");
			call.setData(request);
			call.callService();
			Logger.verifyEquals("400", call.getCode(), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_024() {
		Logger.start(true, "分批导出卖家订单信息成功,测试partitionKey");
		try {
			Logger.comment("准备测试数据");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			OrderCreate o = new OrderCreate();
			String partitionKey = String.valueOf(o.create1_M2cOrder(userId,
					sellerId).getiOrderId());
			for (int i = 0; i < 3; i++) {
				o.create1_M2cOrder(userId, sellerId);
			}
			Thread.sleep(5000l);
			Logger.comment("完成准备测试数据");
			TimeRange time = new TimeRange();
			time.setBegin(YMTDateUtil.getBeforeOrNextDay(-5,
					YMTDateUtil.YMDTHMS_STRING));
			time.setEnd(YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(time);
			request.setSellerId(sellerId);
			request.setPartitionKey(partitionKey);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_025() {
		Logger.start(true, "分批导出卖家订单信息失败, SellerId不存在");
		try {
			request.setSellerId(404);
			request.setProductName("接口自动化测试Test");
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_026() {
		Logger.start(true, "分批导出卖家订单信息, orderstatus=1,2,17,3,4");
		try {
			int SellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			request.setSellerId(SellerId);
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-7,
					YMTDateUtil.YMDTHMS_STRING));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);

			TimeRange paidTime = new TimeRange();
			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-6,
					YMTDateUtil.YMDTHMS_STRING));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0,
					YMTDateUtil.YMDTHMS_STRING));
			request.setPaidTime(paidTime);

			TimeRange deliveredTime = new TimeRange();
			deliveredTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-6,
					YMTDateUtil.YMDTHMS_STRING));
			deliveredTime.setEnd(YMTDateUtil.getBeforeOrNextDay(-1,
					YMTDateUtil.YMDTHMS_STRING));
			request.setDeliveredTime(deliveredTime);

			List<Integer> orderStatus = new ArrayList<Integer>();
			orderStatus.add(OrderStatusEnum.OrderEstablish.getValue());
			orderStatus.add(OrderStatusEnum.AccountPaid.getValue());
			orderStatus.add(OrderStatusEnum.Shipped.getValue());
			orderStatus.add(OrderStatusEnum.Received.getValue());
			orderStatus.add(OrderStatusEnum.SellerAccept.getValue());
			request.setOrderStatus(orderStatus);

			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_027() {
		Logger.start(true, "分批导出卖家订单信息, 测试BuyerNickName的筛选(es)");
		try {
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			String buyerNickName = String.valueOf(EnvSetup
					.getData("BuyUserName"));
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-7,
					YMTDateUtil.YMDTHMS_STRING));
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(0,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);
			request.setSellerId(sellerId);
			request.setBuyerNickName(buyerNickName);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_028() {
		Logger.start(true, "分批导出卖家订单信息, 测试ProductName的筛选(es)");
		try {
			TimeRange createdTime = new TimeRange();
			createdTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-3,
					YMTDateUtil.YMDTHMS_STRING));
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			Logger.comment("准备测试数据");
			String productName = new OrderCreate().create1_M2cOrder(userId,
					sellerId).getsTitle();
			Thread.sleep(2000l);
			Logger.comment("完成准备测试数据");
			createdTime.setEnd(YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING));
			request.setCreatedTime(createdTime);
			request.setSellerId(sellerId);
			request.setProductName(productName);
			call.setData(request);
			call.callService();
			Logger.verifyEquals("200", call.getCode(), "验证code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_ExportSellerOrderInfos_029() {
		Logger.start(true, "订单含有组合商品,分批导出卖家订单信息");
		try {

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder10();

			Order order = placeOrderResp.getOrderList().get(0);

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);

			Thread.sleep(3000);

			request.setSellerId(sellerId);

			TimeRange paidTime = new TimeRange();

			paidTime.setBegin(YMTDateUtil.getBeforeOrNextDay(-1,
					YMTDateUtil.YMDTHMS_STRING));
			paidTime.setEnd(YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING));

			request.setPaidTime(paidTime);

			call.setData(request);
			call.callService();

			Logger.verifyEquals("200", call.getCode(), "验证code");

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}